package com.vr.core.system.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vr.core.system.system.entity.GenericEntity;
import com.vr.core.system.system.service.CommonService;
import com.vr.tool.api.R;
import com.vr.tool.util.BaseQuery;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Description TODO
 * @Author kenson
 * @Date 2024/12/20 22:02
 */

@RestController
@RequestMapping("/base")
public class CommonController {

    @Resource
    private CommonService commonService;

    @PostMapping("/commonPageList")
    public R<Page<Map<String, Object>>> pageList(@RequestBody BaseQuery<Map> query){
        Page<Map<String, Object>> mapPage = commonService.commonPageList(query);
        return R.ok(mapPage);
    }

    @PostMapping("/commonSave")
    public R<Boolean> save(@RequestBody GenericEntity genericEntity){
        return R.ok(commonService.commonSave(genericEntity));
    }

    @PostMapping("/commonUpdate")
    public R<Boolean> update( @RequestBody GenericEntity genericEntity){

        return  R.ok(commonService.commonUpdate(genericEntity));
    }

    @PostMapping("/commonRemoveById")
    public R<Boolean> removeById(@RequestBody GenericEntity genericEntity){
        return  R.ok(commonService.commonDelete(genericEntity));
    }


}



